package com.house.user.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

/**
 * 
 * 
 * @author yangxinyu
 * @email yangxinyu03201@gmail.com
 * @date 2022-04-22 13:34:09
 */
@Data
@TableName("tb_user")
public class UserEntity  implements Serializable ,UserDetails {
	private static final long serialVersionUID = 1L;

	/**
	 * 用户主键
	 */
	@TableId
	private Integer uid;
	/**
	 * 手机号
	 */
	private String phone;
	/**
	 * 头像地址
	 */
	private String portrait;
	/**
	 * 昵称
	 */
	private String nickname;
	/**
	 * 注册时间
	 */
	private Date regTime;
	/**
	 * 角色
	 */
	private Long role;
	/**
	 * 权限表外键
	 */
	private Long pid;
	/**
	 * 最后登录时间
	 */
	private Date lastLoginTime;
	/**
	 * 最后登录IP
	 */
	private String lastLoginIp;
	/**
	 * 	状态 0 禁用 1 启用
	 */
	private Long status;

	/**
	 * 临时验证码
	 */
	@TableField(exist = false)
	private String code;

	@Override
	public Collection<? extends GrantedAuthority> getAuthorities() {
		return null;
	}

	@Override
	public String getPassword() {
		return code;
	}

	@Override
	public String getUsername() {
		return this.nickname;
	}

	@Override
	public boolean isAccountNonExpired() {
		return true;
	}

	@Override
	public boolean isAccountNonLocked() {
		return true;
	}

	@Override
	public boolean isCredentialsNonExpired() {
		return true;
	}

	@Override
	public boolean isEnabled() {
		return true;
	}
}
